cmake_minimum_required(VERSION 3.12)
project(Sobel_Edge_Detection_Demo)

# 查找OpenMP库
find_package(OpenMP REQUIRED)
if(OpenMP_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

# 设置编译选项，开启优化并支持AVX2指令集
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2 -O3")

# 添加可执行文件
add_executable(sobel main.cpp)

# 链接OpenMP库（如果找到）
if(OpenMP_FOUND)
    target_link_libraries(sobel PRIVATE OpenMP::OpenMP_CXX)
endif()